package com.objecteffects.ilmp.persist.jpa;

import com.google.inject.Inject;
import com.google.inject.persist.PersistService;

import org.apache.commons.lang3.exception.ExceptionUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Rusty Wright
 */
class ApplicationInitializer {
    private final transient Logger log = LoggerFactory
            .getLogger(ApplicationInitializer.class);

    @Inject
    ApplicationInitializer(final PersistService service) {
        this.log.debug("starting service");

        try {
            service.start();
        }
        catch (final IllegalStateException ex) {
            /* happens with multiple tests; can't call start more than once */
            this.log.debug("service start: {}", ExceptionUtils.getStackTrace(ex));
        }
    }
}
